/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.List;
import javax.persistence.EntityManager;
import model.Nota;

/**
 *
 * @author ronaldomartins
 */
public class DaoNota  extends Dao{

      @Override
    public List listarTodos() {
        List objs = null;
        EntityManager em = getEntityManager();
        objs = em.createQuery("select n from Nota n").getResultList();
        return objs;
    }
  
    @Override
    public Object buscarPorId(Long id) {
        Object obj = null;
        EntityManager em = getEntityManager();
        obj = em.find(Nota.class, id);
        return obj;
    }
    
    public List listaNotasPorEscolaNotaMateria(Long idSerie, Long idMateria){
        List objs = null;
        EntityManager em = getEntityManager();
        objs = em.createQuery(" select notas from Serie s"+
                                             "  join s.notas as notas"+
                                             "  where s.id = :idSerie and notas.materia.id = :idMateria")
                .setParameter("idSerie", idSerie)
                .setParameter("idMateria", idMateria).getResultList();
        return objs;
    }
    
}
